module.exports = {
  // 使用 uniCloud.importObject, 不如直接用uniCloud.uploadFile
  // async uploadFile({ fileName, base64 }) {
  //   fileName = uuidv4() + fileName.slice(fileName.lastIndexOf('.'))
  //   let result = await uniCloud.uploadFile({
  //     cloudPath: fileName,
  //     fileContent: Buffer.from(base64, 'base64'),
  //     cloudPathAsRealPath: true
  //   })
  //   return result
  // },

  // 使用 uni.request URL化后阿里云接收参数大小不可超过2MB
  async uploadFileUrl() {
    const { body = {} } = this.getHttpInfo()
    const { clientInfo, params } = JSON.parse(body)

    // const MoMenu = uniCloud.databaseForJQL({ clientInfo }).collection('mo-menu')
    // let res = await MoMenu.where('type!=2').orderBy('order_num', 'asc').get({
    //   getTree: {}
    // })

    // fileName = uuidv4() + fileName.slice(fileName.lastIndexOf('.'))
    let result = await uniCloud.uploadFile({
      cloudPath: params.fileName,
      fileContent: Buffer.from(params.base64, 'base64'),
      cloudPathAsRealPath: true
    })

    return result
  }
}
